maintainer="Hoang Nguyen <folliekazetani@protonmail.com>"
pkgname=opcr-policy
pkgver=0.2.21
pkgrel=0
pkgdesc="CLI for building, versioning and publishing authorization policies"
url="https://www.openpolicycontainers.com/"
arch="all !loongarch64"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/opcr-io/policy/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/policy-$pkgver"
options="net" # download Go modules

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local _goldflags="
	-X github.com/opcr-io/policy/pkg/version.ver=$pkgver
	-X github.com/opcr-io/policy/pkg/version.commit=AlpineLinux
	-X github.com/opcr-io/policy/pkg/version.date=$(date -u "+%Y-%m-%dT%H:%M:%SZ" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})
	"

	go build -v -ldflags "$_goldflags" ./cmd/policy/
}

check() {
	go test ./...
}

package() {
	install -Dm755 policy -t "$pkgdir"/usr/bin/
}

sha512sums="
960d9e2ca48f44471c59947ee6e63ff7e713d92eb8d15cd14603c73aca33700cd1d643bacf0e009555b19d6423973eed5d7a6f61fafb184aa0c42a1384704305  opcr-policy-0.2.21.tar.gz
"
